Skip to content

Conversation

@idegtiarenko
Copy link
Contributor

This change tries to simplify EsqlQueryResponse:

  • there are multiple ways to add a conditional json section to response rendering. Here I introduce generic conditionalChunkedXContent and migrate all usages to it.
  • Profile simply wraps List<DriverProfile>. Here I am converting it to record.

@idegtiarenko idegtiarenko added >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.1.0 labels Jun 6, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

public Profile(List<DriverProfile> drivers) {
this.drivers = drivers;
}
public record Profile(List<DriverProfile> drivers) implements Writeable {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we even need that? May be it is worth in-lining List instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I wrote it as a record because I expected we'd add other List<PlanProfile> and List<SomeOtherThingProfile> to it. Mostly, I thought it'd have plan profile in it.

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is helpful, though I think it'd be even more readable to do it the old school way.

public Profile(List<DriverProfile> drivers) {
this.drivers = drivers;
}
public record Profile(List<DriverProfile> drivers) implements Writeable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I wrote it as a record because I expected we'd add other List<PlanProfile> and List<SomeOtherThingProfile> to it. Mostly, I thought it'd have plan profile in it.

Iterator<ToXContent> executionInfoRender = executionInfo != null && executionInfo.hasMetadataToReport()
? ChunkedToXContentHelper.field("_clusters", executionInfo, params)
: Collections.emptyIterator();
return Iterators.concat(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this'd be more readable as a traditional

List<ToXContent> all = new ArrayList<>();
addAsyncProperties(all);
all.add(took)
...

I think so.

@nik9000
Copy link
Member

nik9000 commented Jun 10, 2025

This is helpful, though I think it'd be even more readable to do it the old school way.

But that could be because I'm old.

@idegtiarenko idegtiarenko merged commit 450648a into elastic:main Jun 17, 2025
24 checks passed
@idegtiarenko idegtiarenko deleted the simplify_esql_response branch June 17, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants